// 纳税调整项目明细表
const hsqjCommonJson = {
  '011_30_4': {
    gener: {
      subjectCode: '660208',
      subjectName: '业务招待费',
    },
    small: {
      subjectCode: '560208',
      subjectName: '业务招待费',
    },
  },
  '011_32_4': {
    gener: {
      subjectCode: '660107',
      subjectName: '广告费和业务宣传费',
    },
    small: {
      subjectCode: '560107',
      subjectName: '广告费和业务宣传费',
    },
  },
  '011_36_4': {
    gener: {
      subjectCode: '660306',
      subjectName: '利息支出',
    },
    small: {
      subjectCode: '560306',
      subjectName: '利息支出',
    },
  },
  '011_41_4': {
    gener: {
      subjectCode: '671107',
      subjectName: '税收滞纳金、罚金、罚款',
      formula(amt, result, saasData) {
        const value =
          (
            saasData.find(item =>
              item.subjectCode === '671108' &&
                item.subjectName === '被没收财物的损失') || {}
          ).amt || 0;
        return `${Number.parseFloat(amt) + Number.parseFloat(value)}`;
      },
    },
    small: {
      subjectCode: '571107',
      subjectName: '税收滞纳金、罚金、罚款',
      formula(amt, result, saasData) {
        const value =
          (
            saasData.find(item =>
              item.subjectCode === '571108' &&
                item.subjectName === '被没收财物的损失') || {}
          ).amt || 0;
        return `${Number.parseFloat(amt) + Number.parseFloat(value)}`;
      },
    },
  },
  '011_43_4': {
    gener: {
      subjectCode: '671110',
      subjectName: '赞助支出',
    },
    small: {
      subjectCode: '571110',
      subjectName: '赞助支出',
    },
  },
  '011_142_4': {
    gener: {
      subjectCode: '66020701',
      subjectName: '工资',
    },
    small: {
      subjectCode: '56020701',
      subjectName: '工资',
    },
  },
  '011_144_4': {
    gener: {
      subjectCode: '66020702',
      subjectName: '福利费',
    },
    small: {
      subjectCode: '56020702',
      subjectName: '福利费',
    },
  },
  '011_149_4': {
    gener: {
      subjectCode: '66020703',
      subjectName: '社保费',
    },
    small: {
      subjectCode: '56020703',
      subjectName: '社保费',
    },
  },
};
// 一般企业
const hsqjInputJson1 = {
  // 一般企业收入明细表
  '005_5_2': {
    gener: {
      subjectCode: '6001',
      subjectName: '主营业务收入',
    },
    small: {
      subjectCode: '5001',
      subjectName: '主营业务收入',
    },
  },
  '005_12_2': {
    gener: {
      subjectCode: '6051',
      subjectName: '其他业务收入',
    },
    small: {
      subjectCode: '5051',
      subjectName: '其他业务收入',
    },
  },
  '005_19_2': {
    gener: {
      subjectCode: '630101',
      subjectName: '非流动资产处置净收益',
    },
    small: {
      subjectCode: '530101',
      subjectName: '非流动资产处置净收益',
    },
  },
  '005_22_2': {
    gener: {
      subjectCode: '630102',
      subjectName: '政府补助',
    },
    small: {
      subjectCode: '530102',
      subjectName: '政府补助',
    },
  },
  '005_23_2': {
    gener: {
      subjectCode: '630104',
      subjectName: '盘盈收益',
    },
    small: {
      subjectCode: '530104',
      subjectName: '盘盈收益',
    },
  },
  '005_24_2': {
    gener: {
      subjectCode: '630103',
      subjectName: '捐赠收益',
    },
    small: {
      subjectCode: '530103',
      subjectName: '捐赠收益',
    },
  },
  '005_27_2': {
    gener: {
      subjectCode: '630105',
      subjectName: '汇兑收益',
    },
    small: {
      subjectCode: '530105',
      subjectName: '汇兑收益',
    },
  },
  '005_28_2': {
    gener: {
      subjectCode: '6301',
      subjectName: '营业外收入',
      formula(amt, result) {
        return `${Number.parseFloat(amt) -
          Number.parseFloat(result['005_27_2']) -
          Number.parseFloat(result['005_24_2']) -
          Number.parseFloat(result['005_23_2']) -
          Number.parseFloat(result['005_22_2']) -
          Number.parseFloat(result['005_19_2'])}`;
      },
    },
    small: {
      subjectCode: '5301',
      subjectName: '营业外收入',
      formula(amt, result) {
        return `${Number.parseFloat(amt) -
          Number.parseFloat(result['005_27_2']) -
          Number.parseFloat(result['005_24_2']) -
          Number.parseFloat(result['005_23_2']) -
          Number.parseFloat(result['005_22_2']) -
          Number.parseFloat(result['005_19_2'])}`;
      },
    },
  },
  // 一般企业成本支出明细表
  '007_5_2': {
    gener: {
      subjectCode: '6401',
      subjectName: '主营业务成本',
    },
    small: {
      subjectCode: '5401',
      subjectName: '主营业务成本',
    },
  },
  '007_12_2': {
    gener: {
      subjectCode: '6402',
      subjectName: '其他业务成本',
    },
    small: {
      subjectCode: '5402',
      subjectName: '其他业务成本',
    },
  },
  '007_19_2': {
    gener: {
      subjectCode: '671102',
      subjectName: '非流动资产处置净损失',
    },
    small: {
      subjectCode: '571102',
      subjectName: '非流动资产处置净损失',
    },
  },
  '007_22_2': {
    gener: {
      subjectCode: '671106',
      subjectName: '自然灾害等不可抗力因素造成的损失',
    },
    small: {
      subjectCode: '571106',
      subjectName: '自然灾害等不可抗力因素造成的损失',
    },
  },
  '007_23_2': {
    gener: {
      subjectCode: '671109',
      subjectName: '捐赠支出',
    },
    small: {
      subjectCode: '571109',
      subjectName: '捐赠支出',
    },
  },
  '007_24_2': {
    gener: {
      subjectCode: '671110',
      subjectName: '赞助支出',
    },
    small: {
      subjectCode: '571110',
      subjectName: '赞助支出',
    },
  },
  '007_25_2': {
    gener: {
      subjectCode: '671108',
      subjectName: '被没收财物的损失',
      formula(amt, result, saasData) {
        const value = saasData
          .filter(item => ['671107'].includes(item.subjectCode))
          .reduce((result, item) => {
            result += Number.parseFloat(item.amt || 0);
            return result;
          }, 0);
        return `${Number.parseFloat(amt) + Number.parseFloat(value)}`;
      },
    },
    small: {
      subjectCode: '571108',
      subjectName: '被没收财物的损失',
      formula(amt, result, saasData) {
        const value = saasData
          .filter(item => ['571107'].includes(item.subjectCode))
          .reduce((result, item) => {
            result += Number.parseFloat(item.amt || 0);
            return result;
          }, 0);
        return `${Number.parseFloat(amt) + Number.parseFloat(value)}`;
      },
    },
  },
  '007_26_2': {
    gener: {
      subjectCode: '671103',
      subjectName: '坏账损失',
    },
    small: {
      subjectCode: '571103',
      subjectName: '坏账损失',
    },
  },
  '007_27_2': {
    gener: {
      subjectCode: '671104',
      subjectName: '无法收回的长期债券投资损失',
      formula(amt, result, saasData) {
        const value = saasData
          .filter(item => ['671105'].includes(item.subjectCode))
          .reduce((result, item) => {
            result += Number.parseFloat(item.amt || 0);
            return result;
          }, 0);
        return `${Number.parseFloat(amt) + Number.parseFloat(value)}`;
      },
    },
    small: {
      subjectCode: '571104',
      subjectName: '无法收回的长期债券投资损失',
      formula(amt, result, saasData) {
        const value = saasData
          .filter(item => ['571105'].includes(item.subjectCode))
          .reduce((result, item) => {
            result += Number.parseFloat(item.amt || 0);
            return result;
          }, 0);
        return `${Number.parseFloat(amt) + Number.parseFloat(value)}`;
      },
    },
  },
  '007_28_2': {
    gener: {
      subjectCode: '6711',
      subjectName: '营业外支出',
      formula(amt, result) {
        return `${Number.parseFloat(amt) -
          Number.parseFloat(result['007_19_2']) -
          Number.parseFloat(result['007_22_2']) -
          Number.parseFloat(result['007_23_2']) -
          Number.parseFloat(result['007_24_2']) -
          Number.parseFloat(result['007_25_2']) -
          Number.parseFloat(result['007_26_2']) -
          Number.parseFloat(result['007_27_2'])}`;
      },
    },
    small: {
      subjectCode: '5711',
      subjectName: '营业外支出',
      formula(amt, result) {
        return `${Number.parseFloat(amt) -
          Number.parseFloat(result['007_19_2']) -
          Number.parseFloat(result['007_22_2']) -
          Number.parseFloat(result['007_23_2']) -
          Number.parseFloat(result['007_24_2']) -
          Number.parseFloat(result['007_25_2']) -
          Number.parseFloat(result['007_26_2']) -
          Number.parseFloat(result['007_27_2'])}`;
      },
    },
  },
  // 期间费用明细表
  '010_4_2': {
    gener: {
      subjectCode: '660101',
      subjectName: '职工薪酬',
    },
    small: {
      subjectCode: '560101',
      subjectName: '职工薪酬',
    },
  },
  '010_8_2': {
    gener: {
      subjectCode: '660107',
      subjectName: '广告费和业务宣传费',
    },
    small: {
      subjectCode: '560107',
      subjectName: '广告费和业务宣传费',
    },
  },
  '010_9_2': {
    gener: {
      subjectCode: '660110',
      subjectName: '佣金费',
    },
    small: {
      subjectCode: '560110',
      subjectName: '佣金费',
    },
  },
  '010_16_2': {
    gener: {
      subjectCode: '660109',
      subjectName: '差旅费',
    },
    small: {
      subjectCode: '560109',
      subjectName: '差旅费',
    },
  },
  '010_17_2': {
    gener: {
      subjectCode: '660106',
      subjectName: '保险费',
    },
    small: {
      subjectCode: '560106',
      subjectName: '保险费',
    },
  },
  '010_18_2': {
    gener: {
      subjectCode: '660103',
      subjectName: '运输仓储费',
      formula(amt, result, saasData) {
        const value =
          (
            saasData.find(item =>
              item.subjectCode === '660104' && item.subjectName === '装卸费') || {}
          ).amt || 0;
        return `${Number.parseFloat(amt) + Number.parseFloat(value)}`;
      },
    },
    small: {
      subjectCode: '560103',
      subjectName: '运输仓储费',
      formula(amt, result, saasData) {
        const value =
          (
            saasData.find(item =>
              item.subjectCode === '560104' && item.subjectName === '装卸费') || {}
          ).amt || 0;
        return `${Number.parseFloat(amt) + Number.parseFloat(value)}`;
      },
    },
  },
  '010_19_2': {
    gener: {
      subjectCode: '660102',
      subjectName: '商品维修费',
    },
    small: {
      subjectCode: '560102',
      subjectName: '商品维修费',
    },
  },
  '010_20_2': {
    gener: {
      subjectCode: '660105',
      subjectName: '包装费',
    },
    small: {
      subjectCode: '560105',
      subjectName: '包装费',
    },
  },
  '010_28_2': {
    gener: {
      subjectCode: '6601',
      subjectName: '销售费用',
      formula(amt, result) {
        return `${Number.parseFloat(amt) -
          Number.parseFloat(result['010_4_2']) -
          Number.parseFloat(result['010_8_2']) -
          Number.parseFloat(result['010_9_2']) -
          Number.parseFloat(result['010_16_2']) -
          Number.parseFloat(result['010_17_2']) -
          Number.parseFloat(result['010_19_2']) -
          Number.parseFloat(result['010_20_2']) -
          Number.parseFloat(result['010_18_2'])}`;
      },
    },
    small: {
      subjectCode: '5601',
      subjectName: '销售费用',
      formula(amt, result) {
        return `${Number.parseFloat(amt) -
          Number.parseFloat(result['010_4_2']) -
          Number.parseFloat(result['010_8_2']) -
          Number.parseFloat(result['010_9_2']) -
          Number.parseFloat(result['010_16_2']) -
          Number.parseFloat(result['010_17_2']) -
          Number.parseFloat(result['010_19_2']) -
          Number.parseFloat(result['010_20_2']) -
          Number.parseFloat(result['010_18_2'])}`;
      },
    },
  },
  '010_4_4': {
    gener: {
      subjectCode: '660207',
      subjectName: '职工薪酬',
    },
    small: {
      subjectCode: '560207',
      subjectName: '职工薪酬',
    },
  },
  '010_5_4': {
    gener: {
      subjectCode: '660218',
      subjectName: '劳务费',
    },
    small: {
      subjectCode: '560218',
      subjectName: '劳务费',
    },
  },
  '010_6_4': {
    gener: {
      subjectCode: '660214',
      subjectName: '咨询费',
    },
    small: {
      subjectCode: '560214',
      subjectName: '咨询费',
    },
  },
  '010_7_4': {
    gener: {
      subjectCode: '660208',
      subjectName: '业务招待费',
    },
    small: {
      subjectCode: '560208',
      subjectName: '业务招待费',
    },
  },
  '010_10_4': {
    gener: {
      subjectCode: '660202',
      subjectName: '折旧费',
    },
    small: {
      subjectCode: '560202',
      subjectName: '折旧费',
    },
  },
  '010_12_4': {
    gener: {
      subjectCode: '660204',
      subjectName: '办公费',
    },
    small: {
      subjectCode: '560204',
      subjectName: '办公费',
    },
  },
  '010_13_4': {
    gener: {
      subjectCode: '660217',
      subjectName: '董事会费',
    },
    small: {
      subjectCode: '560217',
      subjectName: '董事会费',
    },
  },
  '010_14_4': {
    gener: {
      subjectCode: '660216',
      subjectName: '租赁费',
    },
    small: {
      subjectCode: '560216',
      subjectName: '租赁费',
    },
  },
  '010_15_4': {
    gener: {
      subjectCode: '660215',
      subjectName: '诉讼费',
    },
    small: {
      subjectCode: '560215',
      subjectName: '诉讼费',
    },
  },
  '010_16_4': {
    gener: {
      subjectCode: '660206',
      subjectName: '差旅费',
    },
    small: {
      subjectCode: '560206',
      subjectName: '差旅费',
    },
  },
  '010_17_4': {
    gener: {
      subjectCode: '660212',
      subjectName: '财产保险费',
    },
    small: {
      subjectCode: '560212',
      subjectName: '财产保险费',
    },
  },
  '010_18_4': {
    gener: {
      subjectCode: '660220',
      subjectName: '快递费',
    },
    small: {
      subjectCode: '560220',
      subjectName: '快递费',
    },
  },
  '010_19_4': {
    gener: {
      subjectCode: '660203',
      subjectName: '修理费',
    },
    small: {
      subjectCode: '560203',
      subjectName: '修理费',
    },
  },
  '010_21_4': {
    gener: {
      subjectCode: '660210',
      subjectName: '技术转让费',
    },
    small: {
      subjectCode: '560210',
      subjectName: '技术转让费',
    },
  },
  '010_22_4': {
    gener: {
      subjectCode: '660209',
      subjectName: '研究费用',
    },
    small: {
      subjectCode: '560209',
      subjectName: '研究费用',
    },
  },
  '010_28_4': {
    gener: {
      subjectCode: '6602',
      subjectName: '管理费用',
      formula(amt, result) {
        return `${Number.parseFloat(amt) -
          Number.parseFloat(result['010_4_4']) -
          Number.parseFloat(result['010_5_4']) -
          Number.parseFloat(result['010_6_4']) -
          Number.parseFloat(result['010_7_4']) -
          Number.parseFloat(result['010_10_4']) -
          Number.parseFloat(result['010_12_4']) -
          Number.parseFloat(result['010_13_4']) -
          Number.parseFloat(result['010_14_4']) -
          Number.parseFloat(result['010_15_4']) -
          Number.parseFloat(result['010_16_4']) -
          Number.parseFloat(result['010_17_4']) -
          Number.parseFloat(result['010_18_4']) -
          Number.parseFloat(result['010_19_4']) -
          Number.parseFloat(result['010_21_4']) -
          Number.parseFloat(result['010_22_4'])}`;
      },
    },
    small: {
      subjectCode: '5602',
      subjectName: '管理费用',
      formula(amt, result) {
        return `${Number.parseFloat(amt) -
          Number.parseFloat(result['010_4_4']) -
          Number.parseFloat(result['010_5_4']) -
          Number.parseFloat(result['010_6_4']) -
          Number.parseFloat(result['010_7_4']) -
          Number.parseFloat(result['010_10_4']) -
          Number.parseFloat(result['010_12_4']) -
          Number.parseFloat(result['010_13_4']) -
          Number.parseFloat(result['010_14_4']) -
          Number.parseFloat(result['010_15_4']) -
          Number.parseFloat(result['010_16_4']) -
          Number.parseFloat(result['010_17_4']) -
          Number.parseFloat(result['010_18_4']) -
          Number.parseFloat(result['010_19_4']) -
          Number.parseFloat(result['010_21_4']) -
          Number.parseFloat(result['010_22_4'])}`;
      },
    },
  },
  '010_9_6': {
    gener: {
      subjectCode: '660303',
      subjectName: '手续费',
    },
    small: {
      subjectCode: '560303',
      subjectName: '手续费',
    },
  },
  '010_24_6': {
    gener: {
      subjectCode: '660305',
      subjectName: '利息收入',
      formula(amt, result, saasData) {
        const value =
          (
            saasData.find(item =>
              item.subjectCode === '660301' && item.subjectName === '利息费用') || {}
          ).amt || 0;
        return `${Number.parseFloat(amt) + Number.parseFloat(value)}`;
      },
    },
    small: {
      subjectCode: '560305',
      subjectName: '利息收入',
      formula(amt, result, saasData) {
        const value =
          (
            saasData.find(item =>
              item.subjectCode === '560301' && item.subjectName === '利息费用') || {}
          ).amt || 0;
        return `${Number.parseFloat(amt) + Number.parseFloat(value)}`;
      },
    },
  },
  '010_25_6': {
    gener: {
      subjectCode: '660302',
      subjectName: '汇兑损失',
    },
    small: {
      subjectCode: '560302',
      subjectName: '汇兑损失',
    },
  },
  '010_26_6': {
    gener: {
      subjectCode: '660304',
      subjectName: '现金折扣',
    },
    small: {
      subjectCode: '560304',
      subjectName: '现金折扣',
    },
  },
  '010_28_6': {
    gener: {
      subjectCode: '6603',
      subjectName: '财务费用',
      formula(amt, result) {
        return `${Number.parseFloat(amt) -
          Number.parseFloat(result['010_9_6']) -
          Number.parseFloat(result['010_24_6']) -
          Number.parseFloat(result['010_25_6']) -
          Number.parseFloat(result['010_26_6'])}`;
      },
    },
    small: {
      subjectCode: '5603',
      subjectName: '财务费用',
      formula(amt, result) {
        return `${Number.parseFloat(amt) -
          Number.parseFloat(result['010_9_6']) -
          Number.parseFloat(result['010_24_6']) -
          Number.parseFloat(result['010_25_6']) -
          Number.parseFloat(result['010_26_6'])}`;
      },
    },
  },
  // 企业经营数据采集
  '004_5_2': {
    gener: {
      subjectCode: '6403',
      subjectName: '税金及附加',
    },
    small: {
      subjectCode: '5403',
      subjectName: '税金及附加',
    },
  },
  '004_9_2': {
    gener: {
      subjectCode: '6701',
      subjectName: '资产减值损失',
    },
    small: {
      subjectCode: '5701',
      subjectName: '资产减值损失',
    },
  },
};

const hsqjInputJson = Object.assign(hsqjInputJson1, hsqjCommonJson);

export {
  hsqjInputJson,
}